package pers.kafka.controller;

import org.apache.kafka.common.utils.SystemTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.kafka.producer.UserLogProducer;

import javax.annotation.PostConstruct;

/**
 * @author
 * @date 2021/1/13 0013 - 上午 9:32
 */
@RestController
public class UserLogController {

    static {
        System.out.println("===UserLogController===");
    }

    @Autowired
    private UserLogProducer kafkaSender;

    @PostConstruct
    public void init(){
        System.out.println("timer:::" + SystemTime.SYSTEM);
    }

    @RequestMapping("/getUserLog")
    public String getUserLog(){
        for (int i = 0; i < 10; i++) {
            //调用消息发送类中的消息发送方法
            kafkaSender.sendLog(String.valueOf(i));
        }
        return null;
    }
}
